﻿/* ----------------------------------------------------------------------------
 * Copyright (c) Philip Stears 
 *
 * This source code is subject to terms and conditions of the Microsoft Public 
 * License (Ms-PL).
 * 
 * By using this source code in any fashion, you are agreeing to be bound 
 * by the terms of the Microsoft Public License.
 * 
 * To request a copy of the Microsoft Public License, send a request by email
 * to license@connectbasic.net.
 *
 * This notice must not be removed from this software.
 * ---------------------------------------------------------------------------- */

namespace ConnectBasic.ObjectModel
{
    using ConnectBasic.Execution;
    using DlrExpression = Microsoft.Linq.Expressions.Expression;

    /// <summary>
    /// The "On Error GoTo [Label]" statement.
    /// </summary>
    public class OnErrorGoToStatement : StatementNodeBase
    {
        private string mLabel;

        /// <summary>
        /// Initializes a new instance of the <see cref="OnErrorGoToStatement" /> class.
        /// </summary>
        /// <param name="label">The label to jump to when an error occurs.</param>
        public OnErrorGoToStatement(string label)
        {
            mLabel = label;
        }

        /// <summary>
        /// Gets the label to which to jump when an error occurs.
        /// </summary>
        public string Label
        {
            get { return mLabel; }
        }

        /// <inheritdoc />
        public override DlrExpression Compile(BasicCodeGenerator gen)
        {

            // TODO: Compilation of OnErrorGotoStatement
            return DlrExpression.Empty();
        }
    }
}
